// 创建外壳组件
import React, {Component} from "react"
import axios from "axios";

// 创建并暴露App组件
export default class App extends Component {
  render() {
    return (
      <div>
        <button onClick={this.getStudentDetail}>点我获取学生数据</button>
        <button onClick={this.getCarDetail}>获取汽车数据</button>
      </div>
    )
  }

  getStudentDetail = () => {
    //  点击获取学生数据按钮的事件
    axios.get("/api1/students").then(res => {
      console.log(res)
    }, (error) => {
      console.log(error)
    })
  }
  getCarDetail = () => {
    //  获取汽车数据
    axios.get("/api2/cars").then(res => {
      console.log(res)
    }, (error) => {
      console.log(error)
    })
  }
}